from math import tan

from kivy.graphics.vertex_instructions import Ellipse, Rectangle
from kivy.metrics import inch

from dryfire.model.spaceModel import OutdoorSpaceModel, DryFireSpaceModel


class OutdoorShapeModel(OutdoorSpaceModel):
    """
    This is a shape in an outdoor target.
    The shape is a circle or a rectangle.
    The shape has a height and width in inches.
    The target has a distance in yards.
    """

    shape_circle = 1
    shape_rectangle = 2
    shapes = [shape_circle, shape_rectangle]

    def __init__(self, width_inches, height_inches, shape, distance_yards, description):
        """
        type: height_inches: float, int
        type: width_inches: float, int
        type: shape: OutdoorShapeModel.shapes
        type: distance_yards: float, int
        type: description: str
        """
        OutdoorSpaceModel.__init__(self, width_inches, height_inches, distance_yards, description)
        self.shape = shape


class DryFireShapeModel(DryFireSpaceModel):
    """
    This is a shape on an indoor target.
    It has a corresponding OutdoorShapeModel object.
    The indoor target has a distance in feet.
    The shape has a graphic which is a kivy.graphics Circle or Rectangle.
    """
    def __init__(self, outdoor_shape_model, distance_feet):
        """
        type: outdoor_shape_model: OutdoorShapeModel
        type: distance_feet: float, int
        """
        DryFireSpaceModel.__init__(self, outdoor_shape_model, distance_feet)

    # properties

    @property
    def graphic(self):
        size = (self.width_pixels, self.height_pixels)
        if self._outdoor_space_model.shape == OutdoorShapeModel.shape_circle:
            return Ellipse(size=size)
        else:  # self._outdoor_space_model.shape == OutdoorShapeModel.shape_rectangle:
            return Rectangle(size=size)
